package com.heu.blood.storge.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.heu.blood.common.aop.ControllerLogAnnotation;
import com.heu.blood.dict.vo.DictTypeVo;
import com.heu.blood.storge.vo.DictTemplateQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.heu.blood.storge.entity.DictTemplateEntity;
import com.heu.blood.storge.service.DictTemplateService;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;



/**
 * 模板字典表项
 *
 * @author lrz
 * @email 2963864804@qq.com
 * @date 2024-04-07 19:31:27
 */
@RestController
@RequestMapping("storge/dicttemplate")
public class DictTemplateController {
    @Autowired
    private DictTemplateService dictTemplateService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dictTemplateService.queryPage(params);

        return R.ok().put("page", page);
    }


    @GetMapping("/queryDictTemplateList")
    @ControllerLogAnnotation(module = "字典类型信息", operate = "查询模板字典管理数据信息")
    public R queryDictTemplateList(){
        List<DictTemplateQueryVo> list = dictTemplateService.queryDictTemplateList();

        return R.ok().put("list", list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		DictTemplateEntity dictTemplate = dictTemplateService.getById(id);

        return R.ok().put("dictTemplate", dictTemplate);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DictTemplateEntity dictTemplate){
		dictTemplateService.save(dictTemplate);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DictTemplateEntity dictTemplate){
		dictTemplateService.updateById(dictTemplate);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		dictTemplateService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
